package com.jwthhealth_pub.wristband.view.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by liuzhen on 2017/12/14.
 */

public class WristbandGuideWeightStandrad extends View {

    private Paint mStandartPaint;

    public WristbandGuideWeightStandrad(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        paint();
    }

    private void paint() {
        mStandartPaint = new Paint();
        mStandartPaint.setStrokeWidth(5);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int height = getHeight();
        int width = getWidth();

        int colorStart = Color.GREEN;
        int colorMiddle = Color.YELLOW;
        int colorEnd = Color.RED;

        int start = Color.parseColor("#ff0000");
        int middle = Color.parseColor("#fff157");
        int end = Color.parseColor("#00ff00");

        LinearGradient backGradient = new LinearGradient(30, height/2, width - 30, height/2, new int[]{start, end}, null, Shader.TileMode.CLAMP);
        mStandartPaint.setShader(backGradient);

        canvas.drawLine(30, height/2, width - 30, height/2, mStandartPaint);

    }
}
